#ifndef __MAZE_H__
#define __MAZE_H__

#include "MazeCell.h"

#include <vector>
#include <boost/smart_ptr/shared_ptr.hpp>



// Maze
class CMaze
{
public:
	CMaze();
	~CMaze();
	void generate(unsigned int uiSizeX, unsigned int uiSizeY);

	inline unsigned int getSizeX() const
	{ return m_uiSizeX; }
	inline unsigned int getSizeY() const
	{ return m_uiSizeY; }
	inline const MazeCellPtr getCell(unsigned int uiX, unsigned int uiY) const
	{
		return m_vecCells[uiY * m_uiSizeX + uiX];
	}

	
private:
	unsigned int		m_uiSizeX;
	unsigned int		m_uiSizeY;
	std::vector<MazeCellPtr>m_vecCells;

	enum eDirection
	{
		north=0,
		east,
		south,
		west,
		maxDirection
	};
	
	void reset();
	void reset(unsigned int uiSizeX, unsigned int uiSizeY);

	inline unsigned int genRangedRndNb(unsigned int uiMin, unsigned int uiMax)
	{
		return (uiMin + rand() % ((uiMax + 1) - uiMin));
	}

	bool getNeighWithIntactWall(const MazeCellPtr& pCenterCell, MazeCellPtr& pResultCell, CMaze::eDirection dir);

};
typedef boost::shared_ptr<CMaze> MazePtr;


#endif // __MAZE_H__